<?php

/**
 * ContactForm class.
 * ContactForm is the data structure for keeping
 * contact form data. It is used by the 'contact' action of 'SiteController'.
 */
class AllTimeSeriesForm extends CFormModel
{
	public $team1;
	public $team2;
	public $totalMatch = 10;
	public $allMatch;
	public $local;
	public $listTeam1;
	public $listTeam2;
	public $listLocal;
	public $matchs;
	public $dataprovider;
	public $valid = false;
	public $pagefield;
	public $sintesis;
		
	/**
	 * Declares the validation rules.
	 */
	public function rules()
	{
		return array(
			// name, email, subject and body are required
			array('team1, team2, local', 'required'),
			array('allMatch, totalMatch', 'matchFilter')
		);
	}
	
	public function matchFilter($attribute,$params)
    {
        if ($this->allMatch==0)
        	if ($this->totalMatch<1)        
            	$this->addError('totalMatch','El valor debe ser mayor a cero.');
    }

	/**
	 * Declares customized attribute labels.
	 * If not declared here, an attribute would have a label that is
	 * the same as its name with the first letter in upper case.
	 */
	public function attributeLabels()
	{
		return array(
			'team1'=>'Equipo 1:',
			'team2'=>'Equipo 2:',
			'totalMatch'=>'Cantidad Partidos',
			'allMatch'=>'Todos',
			'local'=>'Localia:',
		);
	}
	
	public function getAllTimeSeries(){
		$aux = $this->totalMatch;
		$aux=1000;		
		if ($this->allMatch==1){$aux=1000;}
		if ($this->local==2){
			return $dao=Dao::Instance()->getAllTimeSeriesBothLocal($this->team1,$this->team2,$aux);
		}else{		
			return $dao=Dao::Instance()->getAllTimeSeries($this->team1,$this->team2,$aux);
		}		
	}
}